package cn.com.petrochina.lpm3.controller;


import cn.com.petrochina.lpm3.service.TwsuidEdmuserRelationService;
import cn.hutool.http.webservice.SoapClient;
import lombok.RequiredArgsConstructor;
import me.yex.common.core.entity.ResultModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("data/import")
@RequiredArgsConstructor
public class DataImportController {

    private static final Logger log = LoggerFactory.getLogger(DataImportController.class);

    private final TwsuidEdmuserRelationService twsService;


    @GetMapping("/oil")
    public ResultModel<?> index(@RequestParam(required = false) String module,
                                @RequestParam(name = "url_my", required = false) String urlMy) {
        SoapClient client = SoapClient.create("http://www.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx")
                // 设置要请求的方法，此接口方法前缀为web，传入对应的命名空间
                .setMethod("web:getCountryCityByIp", "http://WebXml.com.cn/")
                // 设置参数，此处自动添加方法的前缀：web
                .setParam("theIpAddress", "218.21.240.106");

        // 发送请求，参数true表示返回一个格式化后的XML内容
        // 返回内容为XML字符串，可以配合XmlUtil解析这个响应
        System.out.println(client.send(true));

        return ResultModel.ok();
    }

    @GetMapping("/hello")
    public String hello() {
        return "hello";
    }
}
